package cn.swpu.service;

import cn.swpu.domin.Department;
import cn.swpu.domin.Role;
import cn.swpu.domin.User;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created by 11616 on 2016/7/7.
 */
@Service("testService")
public class TestService {
    @Resource
    private SessionFactory sessionFactory;
    @Transactional
    public void saveUsers(){
        Session session = sessionFactory.getCurrentSession();

        session.save(new User());
    }
    @Transactional
    public void saveRoles(){
        Session session = sessionFactory.getCurrentSession();
        session.save(new Role());
    }
    @Transactional
    public void saveDepartment(){
        Session session = sessionFactory.getCurrentSession();
        session.save(new Department());
    }
}
